package prodcon;

public class Producer extends Thread {
	private Buffer output;

	public Producer(Buffer buffer) {
		output = buffer;
		start();
	}

	public void run() {
		try {
			for (;;) {
				int datum = (int) (Math.random() * 100000);
				output.put(datum);
				System.out.println("Put " + datum);
				sleep((long) (Math.random() * 2000));
			}
		} catch (InterruptedException ie) {
			System.out.println("Sender completed");
			return;
		}
	}
}